/***************************************************************************
 *   Copyright (C) 2008 by Tomasz Dubik                                    *
 *   tdubik@gmail.com                                                      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include <QDebug>
#include <QUrl>

#include "configdlg.h"

ConfigDlgImpl::ConfigDlgImpl(QWidget* parent):QDialog(parent)
{

	setupUi(this);
	connect(this, SIGNAL(setHostSignal(const QString&)), m_host, SLOT(setText(const QString&)));
	connect(this, SIGNAL(setUsernameSignal(const QString&)), m_username, SLOT(setText(const QString&)));
	connect(this, SIGNAL(setPasswordSignal(const QString&)), m_password, SLOT(setText(const QString&)));
}

void ConfigDlgImpl::setHost(const QString& host)
{
		emit(setHostSignal(host));
}

void ConfigDlgImpl::setUsername(const QString& username)
{
	emit(setUsernameSignal(username));
}

void ConfigDlgImpl::setPassword(const QString& password)
{
	emit(setPasswordSignal(password));
}

void ConfigDlgImpl::setSavePassword(const bool& save)
{
	if( save )
		m_rememberPass->setCheckState(Qt::Checked);
	else
		m_rememberPass->setCheckState(Qt::Unchecked);
}

void ConfigDlgImpl::setUsePassiveFtp(const bool& passive)
{
	if( passive )
		m_passiveFtp->setCheckState(Qt::Checked);
	else
		m_passiveFtp->setCheckState(Qt::Unchecked);
}

const QString ConfigDlgImpl::host()
{
	return m_host->text();
}

const QString ConfigDlgImpl::username()
{
	return m_username->text();
}

const QString ConfigDlgImpl::password()
{
	return m_password->text();
}

const bool ConfigDlgImpl::savePassword()
{
	return m_rememberPass->checkState() == Qt::Checked;
}

const bool ConfigDlgImpl::usePassiveFtp()
{
	return m_passiveFtp->checkState() == Qt::Checked;
}

void ConfigDlgImpl::setData(const QString host,
			const QString username,
			const QString password,
			bool usePassiveFtp,
			bool storePassword)
{
	qDebug() << host;
	setHost(host);
	setUsername(username);
	setPassword(password);
	setUsePassiveFtp(usePassiveFtp);
	setSavePassword(storePassword);
}

//eof
